#!/usr/bin/env python
#coding: utf-8
'''
Created on 2017年2月17日

@author: Administrator
'''


from django.db import models

from common import settings

class LikeModel(models.Model):
    '''
    class: 所有使用了Like的都必须继承此父类
    '''
    
    like_count = models.IntegerField(default=0, verbose_name=u'赞数')
    
    class Meta:
        abstract = True
        
        
class TimeModel(models.Model):
    '''
    class: 包含创建和修改时间的基础类
    '''
    create_time = models.DateTimeField(auto_now_add=True, db_index=True, verbose_name=u'创建时间')
    modify_time = models.DateTimeField(auto_now=True, db_index=True, verbose_name=u'更新时间')

    class Meta:
        abstract = True

class StateModel(models.Model):
    '''
    class: 包含记录状态的基础类0--正常 9--删除
    '''
    state = models.IntegerField(choices=settings.STATE_CHOICES, default=settings.StateEnum.VALID, db_index=True, verbose_name=u'记录状态')

    class Meta:
        abstract = True
        
    #逻辑删除
    def logic_delete(self):
        self.state = 9
        self.save()
